<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <include file="Public:header" />
  <!--[if lt IE 9]>
    <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>
<body>
  <include file="Public:body_top" />

  <div class="container-fluid">
    <div class="row">
      <div class="col-sm-3 col-md-2 sidebar hidden-xs">
        <div class="menu">
          <dl>
            <dt><i class="cm-order"></i>小程序</dt>
            <dd class="active"><a href="{:U('Apps/xcx_edit')}">小程序配置</a></dd>
            <dd><a href="{:U('Apps/xcx_edit')}&tpl=xcx_msg_edit">小程序模板消息</a></dd>
            <dd><a href="{:U('Apps/xcx_edit')}&tpl=storage">存储配置</a></dd>
            <dd><a href="{:U('Apps/xcx_edit')}&tpl=sms">短信配置</a></dd>
            <dd><a href="{:U('Apps/xcx_edit')}&tpl=withdraw">提现配置</a></dd>
            <dd><a href="{:U('Mode/index')}">首页模式图标</a></dd>
            <!-- <dd><a href="{:U('Apps/xcx_edit')}&tpl=payment">结算配置</a></dd> -->
          </dl>
          <dl>
            <dt><i class="cm-advert"></i>广告管理</dt>
            <dd><a href="{:U('Adverts/index')}">广告列表</a></dd>
            <dd><a href="{:U('Adverts/add')}">新建广告</a></dd>
          </dl>
          <dl>
            <dt><i class="icon-uniE611"></i>帮助管理</dt>
            <dd><a href="{:U('Helps/index')}">帮助列表</a></dd>
            <dd><a href="{:U('Helps/add')}">新建帮助</a></dd>
          </dl>
        </div>
      </div>
      <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
        <div class="main-hd">
          <h5>编辑小程序</h5>
        </div>

        <div class="main-bd">
          <div class="form-box">
            <form class="form-horizontal" method="post" action="{:U('Apps/xcx_update')}" enctype="multipart/form-data">
              <div class="form-group">
                <label class="col-sm-2 control-label">小程序名称</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name="name" id="name" value="{$app.name}">
                </div>
                <label class="col-sm-2 control-label">分享描述</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name="descrip" value="{$app.descrip}">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">公司名称</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name="company_name" id="company_name" value="{$app.company_name}">
                </div>
                <label class="col-sm-2 control-label">优选主标题</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name="hot_title" value="{$app.hot_title}">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">客服微信号</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name="kfwechat" id="kfwechat" value="{$app.kfwechat}">
                </div>
                <label class="col-sm-2 control-label">客服手机号</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name="kfphone" id="kfphone" value="{$app.kfphone}">
                </div>
              </div>
              <div class="form-group">

              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">小程序APPID</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name="cappid_applet" id="cappid_applet" value="{$app.cappid_applet}">
                </div>
                <label class="col-sm-2 control-label">小程序APPSECRET</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name="cappsecret_applet" id="cappsecret_applet" value="{$app.cappsecret_applet}">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">微信支付MCHID</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name="mch_id" id="mch_id" value="{$app.mch_id}">
                </div>
                <label class="col-sm-2 control-label">微信支付KEY</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name="xcx_key" id="xcx_key" value="{$app.xcx_key}">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">微信支付证书apiclient_cert</label>
                <div class="col-sm-8">
                  <textarea name="wxpay_cert" placeholder="-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----" class="form-control" rows="8" cols="80">{$app.wxpay_cert}</textarea>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">微信支付证书apiclient_key</label>
                <div class="col-sm-8">
                  <textarea name="wxpay_key" placeholder="
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----" class="form-control" rows="8" cols="80">{$app.wxpay_key}</textarea>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">商户是否审核</label>
                <div class="col-sm-3">
                  <input type="radio" value=1 name="audit_types" <if condition="$app.audit_types eq 1"> checked</if> > 是
                  <input type="radio" value=2 name="audit_types" <if condition="$app.audit_types eq 2"> checked</if> > 否
                </div>
                <label class="col-sm-2 control-label">首页模式</label>
                <div class="col-sm-3">
                  <input type="radio" value=1 name="index_types" <if condition="$app.index_types eq 1"> checked</if> > 默认模式
                  <input type="radio" value=2 name="index_types" <if condition="$app.index_types eq 2"> checked</if> > 小店优选
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">收货时间（天）</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name="receive_days" id="receive_days" value="{$app.receive_days}">
                </div>
                <label class="col-sm-2 control-label">售后时间（天）</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name="aftersale_days" id="aftersale_days" value="{$app.aftersale_days}">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">是否隐藏搜索框</label>
                <div class="col-sm-3">
                  <input type="radio" value=0 name="is_search" <if condition="$app.is_search eq 0"> checked</if> > 隐藏
                  <input type="radio" value=1 name="is_search" <if condition="$app.is_search eq 1"> checked</if> > 显示
                </div>

                <label class="col-sm-2 control-label">版权链接</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name="link" value="{$app.link}">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label ">分享图</label>
                <div class="col-sm-1">
                  <div class="uploadimg" id="uploadimg">
                    <i class="cm-plus"></i>
                    <input type="file" name="share_img" data-id="share-img" class="file-input">
                  </div>
                </div>
                <div class="col-sm-4">
                  <img id="share-img" src="{$app.share_img}" style=" width:78px; height:78px;">
                  <span class="tips">尺寸:500x400</span>
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label ">店铺登录图</label>
                <div class="col-sm-1">
                  <div class="uploadimg" id="uploadimg">
                    <i class="cm-plus"></i>
                    <input type="file" name="shop_login_logo" data-id="shop-login-img" class="file-input">
                  </div>
                </div>
                <div class="col-sm-4">
                  <img id="shop-login-img" src="{$app.shop_login_logo}" style=" width:78px; height:78px;">
                  <span class="tips">尺寸:180x180</span>
                </div>
              </div>
              <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                  <input type="hidden" name="id" value="{$app.id}">
                  <input type="hidden" name="tpl" value="{$tpl}">
                  <input type="submit" class="btn btn-primary" value="提交">
                </div>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
</body>
<script type="text/javascript">
  if (typeof FileReader == 'undefined') {
    $('.uploadimg').html('<h1>当前浏览器不支持FileReader接口</h1>');
  }

  $('.file-input').change(function() {
    console.log('aaa')
    var file = this.files[0];
    console.log(file)
    var reader = new FileReader();
    var that = $(this);
    reader.onload = function(e) {
      var img = $('#' + that.attr('data-id'));
      img.attr('src', e.target.result)
    }

    reader.readAsDataURL(file);
  })
</script>

</html>